<?php


class test extends mysql{
    function default(){
        $sql = "select * from city;";
        $data = $this->select_all($sql);
        $sql = "city where d_id = 0;";
        $city_num = $this->get_total_rows($sql);
        $sql = "city where d_id = 1;";
        $school_num = $this->get_total_rows($sql);
        $sql = "city where d_id = 2;";
        $project_num = $this->get_total_rows($sql);
        $sql = "select * from city where d_id = 1;";
        $school = $this->select_all($sql);


        /*$arr = array(
            0 => '请选择校区'
        );
        for ($i = 1;$i <= 3;$i++){
            $sql = "select city_name as ' ' from city where p_id = $i;";
            $arr[$i] = $this->select_all($sql);
        }*/


        $arr = array(
            0 => array(
                0 => '请选择校区'
            )
        );
        for ($i = 1;$i <= $city_num;$i++){
            $n = $i - 1;
            $sql = "select city_id from city where p_id = 0 limit $n,1;";
            $city_id = $this->select_one($sql);
            $b = $city_id['city_id'];
            $sql = "select city_name as ' ' from city where p_id = $b;";
            $data = $this->select_all($sql);
            $num = count($data);
            for ($j = 0;$j < $num;$j++){
                $sql = "select city_name from city where p_id = $b limit $j,1;";
                $city_name = ($this->select_one($sql))['city_name'];
                $arr[$i][$j] = $city_name;
            }
        }


        /*foreach ($data as $key => $value){
            for ($i = 0;$i < $city_num;$i++){
                for($j = 0;$j < $school_num;$j++){
                    $arr[$i][$j] = $value['city_name'];
                }
            }
        }*/

        print_r($arr);
        exit();
    }
}